﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.Helper;
using BCGC.BLL.BusinessObject;
using Jalal.Library.Utility;

public partial class Admin_EmailTemplates_AddEmailTemplate : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Create_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            string title = Security.BindStringInput(ddlTemplateTitle.SelectedValue, SecurityLevel.Three);
            if (!EmailTemplate.TemplateAlreadyExists(title) && EmailTemplate.Create(title,
                Security.BindStringInput(tbxTemplateSubject.Text, SecurityLevel.Three),
                Security.BindStringInput(fckMailTemplateBody.Value, SecurityLevel.Zero)))
            {
                uccResponse.SetSuccessMessage("Email template successfuly created");
                ClearInput();
            }
            else
                uccResponse.SetFailMessage("Failed to create email template");
        }
    }

    private void ClearInput()
    {
        ddlTemplateTitle.SelectedValue = "NA";
        tbxTemplateSubject.Text = string.Empty;
        fckMailTemplateBody.Value = string.Empty;
    }
}
